package com.interview.javabasic.thread;

import cn.Leecode.Soution;

import java.util.concurrent.CountDownLatch;

/*
@李子宁
Happy,happy everyday!
冲鸭！
2021/3/2

*/
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);

        for (int i = 0; i < 6; i++) {
            new Thread(() ->{
                System.out.println(Thread.currentThread().getName() + "Go out!");
                countDownLatch.countDown();//数量 -1
            },String.valueOf(i)).start();
        }

        countDownLatch.await();//等待计数器归零，然后再向下执行
        System.out.println("Close Door");
    }
}
